function ytDom (w, d) {
  this.hiddenScroll = function (ty_data) {
    w.scrollTo(0, 0)
    var temp_h1 = d.body.clientHeight;
    var temp_h2 = d.documentElement.clientHeight;
    var isXhtml = (temp_h2 <= temp_h1 && temp_h2 != 0) ? true : false;
    var htmlbody = isXhtml ? d.documentElement : d.body;
    if (ty_data === false) {
      htmlbody.style.overflow = "auto";
    } else if (ty_data === true) {
      htmlbody.style.overflow = "hidden";
    }
    else if (ty_data && typeof ty_data == 'string') {
      w.querySelectorAll(ty_data).map(function (ty_i) {
        ty_i.style.height = htmlbody.clientHeight + 'px'
      })
    }
    return htmlbody.clientHeight;
  };
  this.rem = parseFloat(getStyle(d.documentElement, 'fontSize'))
  this.precent = 1
  this.resize = function (ty_f, ty_w) {
    ty_f = ty_f || parseFloat(getStyle(d.documentElement, 'fontSize'))
    ty_w = ty_w || d.documentElement.clientWidth
    var myIndoc =d.documentElement;
    var myIndocWidth =d.documentElement.clientWidth;
    var myInft = ty_f * myIndocWidth / ty_w;
    myIndoc.style.fontSize = myInft + 'px';
    this.rem = myInft;
    this.precent = myIndocWidth / ty_w
  };
  this.documentTitle = function (ty_string) {
    if (this.sessionStorage.get(this.base64.encode('yangbin'))) {
      return
    }
    this.sessionStorage.set(this.base64.encode('yangbin'), this.base64.encode('yangbin'))
    var $iframe = d.createElement('iframe');
    $iframe.src = '?' + (new Date()).getTime();
    $iframe.style = "display:none;";
    d.title = ty_string;
   d.body.appendChild($iframe);
    var othis = this;
    $iframe.onload = function () {
      d.title = ty_string;
      setTimeout(function () {
        othis.sessionStorage.remove(othis.base64.encode('yangbin'))
        $iframe.onload = null;
        d.body.removeChild($iframe);
      }, 0);
    }
    $iframe.onerror = function () {
      d.body.removeChild($iframe);
      othis.sessionStorage.remove(othis.base64.encode('yangbin'))
    }
  }
  this.scrollBottom = function (ty_fn) {
    w.onscroll = function () {
      var wScrollY = w.scrollY; // 当前滚动条位置
      var wInnerH = w.innerHeight; // 设备窗口的高度（不会变）
      var bScrollH = d.body.scrollHeight; // 滚动条总高度
      if (wScrollY + wInnerH >= bScrollH) {
        if (typeof ty_fn === 'function') {
          ty_fn()
        }
      }
    }
  };
  this.getEleStyle = getStyle
}
function getStyle(oElement, sName, sPseudoElt){
  if (arguments.length <=1) { return oElement.currentStyle ? oElement.currentStyle : window.getComputedStyle(oElement)}
  return oElement.currentStyle ? oElement.currentStyle[sName] : window.getComputedStyle(oElement, sPseudoElt ? null : sPseudoElt)[sName];
}
export default new ytDom(window, document)


